import { ref, reactive } from 'vue'

// 状态栏高度
const statusBarHeight = ref(0)
// 内容高度
const contentHeight = ref(0)

// 底部安全区域高度
const safeAreaHeight = ref(0)

// 胶囊信息
const capsule = reactive(uni.getMenuButtonBoundingClientRect())

export function useSystem() {
    const res = uni.getSystemInfoSync()

    // 状态栏高度
    statusBarHeight.value = res.statusBarHeight
    // navbar高度
    if (res.system.indexOf('iOS') > -1) {
        contentHeight.value = 44
    } else {
        contentHeight.value = 48
    }

    // 底部安全区域高度
    // #ifdef MP-WEIXIN
    safeAreaHeight.value = res.screenHeight - res.safeArea.bottom
    // #endif
    // #ifndef MP-WEIXIN
    safeAreaHeight.value = res.safeAreaInsets.bottom
    // #endif

    return {
        statusBarHeight,
        contentHeight,
        safeAreaHeight,
        capsule,
    }
}
